//
//  HPTabBarViewController.swift
//  TLenPoint
//
//  Created by Docker on 2018/3/21.
//  Copyright © 2018年 Docker. All rights reserved.
//

import UIKit

class HPTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

       addChildViewController(childController: HPHomeMViewController(), title: "首页", imageName: "home")
       addChildViewController(childController: HPMineViewController(), title: "我的", imageName: "me")
    }

    func addChildViewController(childController: UIViewController,title:String,imageName:String) {
        childController.tabBarItem.image = UIImage(named: imageName)
        //  设置图片使用原始方式渲染
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selete")?.withRenderingMode(.alwaysOriginal)
        //  设置文字颜色的属性
        childController.tabBarItem.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.orange], for: .selected)
        //  设置文字大小
        childController.tabBarItem.setTitleTextAttributes([NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14)], for: .normal)
        childController.title = title
        //  创建导航控制器
        let nav = HPNavViewController(rootViewController: childController)
        
        //  添加子视图控制器
        addChildViewController(nav)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
